﻿using Padsurface.CoreAudio.Components.MMDevice.Interfaces;
using System;
using System.Runtime.InteropServices;

namespace Padsurface.CoreAudio.Components.MMDevice
{
    /// <summary>
    /// The Windows Multimedia Device (MMDevice) API enables audio clients to discover audio endpoint devices, 
    ///     determine their capabilities, and create driver instances for those devices
    /// </summary>
    public class WindowsMultimediaDevice
    {
        /// <summary>
        /// Enables Windows Store apps to access preexisting Component Object Model (COM) interfaces in the WASAPI family
        /// </summary>
        /// <param name="deviceInterfacePath">A device interface ID for an audio device. 
        ///     This is normally retrieved from a DeviceInformation object or one of the methods of the MediaDevice class.</param>
        /// <param name="iid">The IID of a COM interface in the WASAPI family, such as IAudioClient.</param>
        /// <param name="activationParams">Interface-specific activation parameters.</param>
        /// <param name="completionHandler">An interface implemented by the caller that is called by Windows when the result of the activation procedure is available.</param>
        /// <param name="createAsync">Returns an IActivateAudioInterfaceAsyncOperation interface that represents the asynchronous operation of activating the requested WASAPI interface.</param>
        /// <returns>HRESULT: If the method succeeds, it returns S_OK</returns>
        [DllImport("Mmdevapi.dll", ExactSpelling = true)]
        public static extern int ActivateAudioInterfaceAsync(
            [In, MarshalAs(UnmanagedType.LPWStr)] string deviceInterfacePath,
            [In, MarshalAs(UnmanagedType.LPStruct)] Guid iid,
            [In] IntPtr activationParams,
            [In] IActivateAudioInterfaceCompletionHandler completionHandler,
            out IActivateAudioInterfaceAsyncOperation createAsync);
    }
}